package com.xidian.zhiancloud.controller.chemicalsManagement.dangerousPart;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.service.chemicalsManagement.chemicalManager.dangerousPart.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;



/**
 * 危化品管理 主页
 *
 * @Author: Egoist
 * @Date: 2020/11/10 17:31
 */
@RestController
@RequestMapping("/DangerousChemicalHome")
public class DangerousChemicalHomeController extends BaseController {

    @Autowired
    HomeService homeService;

    /**
     * 获取待归还、待领取、待报废、待出库、待审批数量
     *
     * @return 返回 Map
     */
    @GetMapping("/getStaticInfo")
    public ResultDTO<Map<String, Integer>> getStaticInfo(){
        Long companyId = getSessionUserCompanyId();
        Long userId = getSessionUserid();
        return ResultDTO.successOf(homeService.getStaticInfo(companyId, userId), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 获取危化品类型列表(表的列名)
     *
     * @return 返回类型名称列表
     */
    @GetMapping("/getTypeName")
    public ResultDTO<List<String>> getTypeName() {
        Long companyId = getSessionUserCompanyId();
        return ResultDTO.successOf(homeService.getTypeName(companyId), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 获取部门拥有的所有危化品类别(表的数据源)
     *
     * @return 返回 Map 对象
     */
    @GetMapping("/getTypeInDepartment")
    public ResultDTO<List<Map>> getTypeInDepartment() {
        Long companyId = getSessionUserCompanyId();
        return ResultDTO.successOf(homeService.getTypeInDepartment(companyId), GeneralResponseEnums.SUCCESS);
    }


}
